package com.rabbitmq.Controller;

import com.alibaba.fastjson.JSON;
import com.rabbitmq.Entity.RabbitMQInfo;
import com.rabbitmq.RabbitMQ.RabbitMQSender;
import com.rabbitmq.Service.JpaService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class TestController {
    @Autowired
    JpaService jpaService;

    @Autowired
    private RabbitMQSender rabbitMQSender;

    @RequestMapping("/helloString")
    public void HelloString() throws Exception {
        rabbitMQSender.sendString();
    }

    @RequestMapping("/helloObj")
    public void HelloObj() throws Exception {
        rabbitMQSender.sendObj();
    }

    @RequestMapping("/delay")
    public void Delay() throws Exception {
        rabbitMQSender.sendDelay();
    }

    @RequestMapping("/getMQInfo")
    public String getMQInfo() {
        RabbitMQInfo mqInfo = JSON.parseObject(jpaService.findValueByKey("gs-rabbitmq-info"),RabbitMQInfo.class);
        return JSON.toJSONString(mqInfo);
    }
}
